//
//  ZHClinicView.m
//  Doctor
//
//  Created by liuzhishan on 15/12/22.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHClinicView.h"
#define  CENTERWIGHT  (200 * WIDPro)
@interface ZHClinicView ()

@property (strong, nonatomic)  UILabel *leftLable;
@property (strong, nonatomic)  UILabel *centerLable;
@property (strong, nonatomic)  UILabel *rightLable;

@end

@implementation ZHClinicView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addChildViews];
    }
    return self;
}

-(void)addChildViews
{
    
    self.centerLable = [[UILabel alloc]init];
    self.centerLable.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.centerLable];
    
     [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationLessThanOrEqual toItem:nil attribute:NSLayoutAttributeWidth multiplier:1.0 constant:CENTERWIGHT]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
    
    
     [self addConstraint:[NSLayoutConstraint constraintWithItem:self.centerLable attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
    
    
    
   
  
    
    self.leftLable = [[UILabel alloc]init];
    self.leftLable.textAlignment = NSTextAlignmentRight;
    self.leftLable.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:self.leftLable];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:NSLayoutAttributeRight relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeLeft) multiplier:1.0 constant:-20]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:(NSLayoutAttributeCenterY) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeCenterY) multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.leftLable attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:60*WIDPro]];
    
    
    

    self.rightLable = [[UILabel alloc]init];
    self.rightLable.translatesAutoresizingMaskIntoConstraints = NO;
    
      [self addSubview:self.rightLable];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeLeft) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeRight) multiplier:1.0 constant:20]];
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeCenterY) relatedBy:(NSLayoutRelationEqual) toItem:self.centerLable attribute:(NSLayoutAttributeCenterY) multiplier:1.0 constant:0]];
    
    [self addConstraint:[NSLayoutConstraint constraintWithItem:self.rightLable attribute:(NSLayoutAttributeRight) relatedBy:(NSLayoutRelationLessThanOrEqual) toItem:self attribute:(NSLayoutAttributeRight) multiplier:1.0 constant: -5]];
    
    
 
 
    self.centerLable.textColor = [UIColor whiteColor];
    self.leftLable.textColor = [UIColor whiteColor];
    self.rightLable.textColor = [UIColor whiteColor];
    
    self.centerLable.font = [UIFont systemFontOfSize:30*WIDPro - 2];
    self.leftLable .font = [UIFont systemFontOfSize:30*WIDPro - 2];
    self.rightLable.font = [UIFont systemFontOfSize:30*WIDPro - 2];
    
    
    
    
}

-(void)setClinicName:(NSString *)clinicName andUSerName:(NSString *)userName andTelephone:(NSString *)teleNub{
    
    self.centerLable.text = [NSString stringWithFormat:@"负责人:%@",userName];
    [self.centerLable sizeToFit];
    
    self.leftLable.text = [NSString stringWithFormat:@"诊所名称:%@",clinicName];
    [self.leftLable sizeToFit];
    self.rightLable.text = [NSString stringWithFormat:@"联系方式:%@",teleNub];
    [self.rightLable sizeToFit];
    
}



@end
